#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
string t = "";
vector<int> A;

bool isPrime(int x) {
    int divisors = 0;
    for (int i = 1; i <= x; ++i) {
        if (x % i == 0) {
            divisors++;
        }
    }
    return divisors == 2;
}

int main() {
    for (int x = 100; x < 1000; ++x) {
        if (isPrime(x)) {
            A.push_back(x);
        }
    }

    string input;
    getline(cin, input);
    vector<string> stroka;
    string word = "";
    for (char c : input) {
        if (c == ' ') {
            stroka.push_back(word);
            word = "";
        } else {
            word += c;
        }
    }
    stroka.push_back(word);

    for (const auto& s : stroka) {
        if (s == "zero") t += '0';
        else if (s == "one") t += '1';
        else if (s == "two") t += '2';
        else if (s == "three") t += '3';
        else if (s == "four") t += '4';
        else if (s == "five") t += '5';
        else if (s == "six") t += '6';
        else if (s == "seven") t += '7';
        else if (s == "eight") t += '8';
        else if (s == "nine") t += '9';
    }

    int target = stoi(t);
    if (target >= 100 && target < 1000 && stroka.size() == 3) {
        int closest = A[0];
        int minDiff = abs(target - A[0]);
        for (int i = 1; i < A.size(); ++i) {
            int diff = abs(target - A[i]);
            if (diff < minDiff) {
                minDiff = diff;
                closest = A[i];
            }
        }
        cout << closest << endl;
    } else {
        cout << "Wrong input" << endl;
    }

    return 0;
}
